#!/usr/bin/python

import os
import hashlib


def getMeta(filepath):
	"""
	Generate metadata for the file
	"""

	meta = {}

	# Get the filename by itself
	meta['filename'] = os.path.basename(filepath)

	try:
		filehandle = open(filepath, "rb")
		data = filehandle.read()
	except IOError, e:
		print "Error: " + e.strerror
		print "Could not open " + filepath + "for reading"
		sys.exit(1)
		
	meta['size'] = os.path.getsize(filepath)
	meta['md5'] = hashlib.md5(data).hexdigest()
	meta['sha1'] = hashlib.sha1(data).hexdigest()
	meta['sha256'] = hashlib.sha256(data).hexdigest()
	
	filehandle.close()
	
	return metadata